
#!/user/bin/env python3
# -*- coding: utf-8 -*-


import http.server
import socketserver
import os,sys

sys_argv=sys.argv

PORT=sys_argv[1] if 1 < len(sys_argv) else 5188
DIRECTORY=sys_argv[2] if 2 < len(sys_argv) else os.getcwd()

# PORT = 8000  # 可以根据需要更改端口号
# DIRECTORY = r"E:\Python\python3\fileServices\dist"  # 替换为您要共享的目录路径

os.chdir(DIRECTORY)  # 设置工作目录为指定目录

Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", int(PORT)), Handler) as httpd:
    #print("服务器正在端口", PORT, "上运行，共享目录:", DIRECTORY)
    print(f'Specify Port: "fileServices.exe 5188"')
    print(f'Specify Port and directory: "fileServices.exe 5188 C:\directory"')
    print(f'')
    print(f"Mapping directory: {DIRECTORY}")
    print(f'')
    print(f"Access address: http://127.0.0.1:{PORT}")
    print(f"Access address: http://localhost:{PORT}")
    print(f'')
    httpd.serve_forever()


# pyinstaller -F --icon=./images/icon48.ico fileServices.py